package cn.mrlong.tools.constant

import java.awt.Toolkit
import java.awt.datatransfer.Clipboard
import java.nio.file.Path
import java.nio.file.Paths
import java.util.*
import java.util.concurrent.atomic.AtomicBoolean
import javax.swing.BorderFactory
import javax.swing.border.Border

interface PluginConstant {
    companion object {
        const val TOOLWINDOW_ID: String = "Notebook"

        /**
         * 图片格式
         */
        const val JPG: String = "jpg"
        const val JPEG: String = "jpeg"
        const val PNG: String = "png"
        const val GIF: String = "gif"

        /**
         * 图片文件最大空间
         */
        const val MAX_LENGTH: Long = (1024 * 1024 * 10).toLong()
        const val ThumbExtension: String = "_mini"
        const val ThumbSizeMini: Int = 100
        const val ThumbSizeMax: Int = 2000
        val IMG_EXTENSION_LIST: ArrayList<String> = ArrayList(Arrays.asList(JPG, JPEG, PNG, GIF))

        /**
         * 缓存是否正在清理
         */
        val IsClearing: AtomicBoolean = AtomicBoolean(false)

        val FOCUS_LOST_BORDER: Border = BorderFactory.createEtchedBorder()
        val FOCUS_GAINED_BORDER: Border = BorderFactory.createRaisedBevelBorder()

        const val NOTIFICATION_ID_IMPORT_EXPORT: String = "Notebook Import/Export"
        const val NOTIFICATION_CLEAR_CACHE: String = "Notebook Clear Cache"
        const val DEFAULT_NOTIFICATION_GROUP_ID: String = "Notebook Plugin"


        /**
         * User directory
         * e.g. Windows OS :
         * USER_HOME_PATH ==> C:\Users\Administrator(Your Username)
         */
        val USER_HOME_PATH: String = System.getProperty("user.home")

        /**
         * Data directory of this plugin:
         * USER_HOME_PATH/.ideaNotebooksFile
         */
        val PROJECT_DB_DIRECTORY_PATH: Path = Paths.get(USER_HOME_PATH, ".ideaNotebooksFile")

        /**
         * The image data of this plugin is stored here:
         * USER_HOME_PATH/.ideaNotebooksFile/notebook_images
         */
        val IMAGE_DIRECTORY_PATH: Path = PROJECT_DB_DIRECTORY_PATH.resolve("notebook_images")

        /**
         * Temporary image data of this plugin, stored here:
         * USER_HOME_PATH/.ideaNotebooksFile/notebook_images_temp
         */
        val TEMP_IMAGE_DIRECTORY_PATH: Path = PROJECT_DB_DIRECTORY_PATH.resolve("notebook_images_temp")

        /**
         * SQLite database file for this plugin:
         * USER_HOME_PATH/.ideaNotebooksFile/notebooks.db
         */
        val DB_FILE_PATH: Path = PROJECT_DB_DIRECTORY_PATH.resolve("notebooks.db")


        val CLIPBOARD: Clipboard = Toolkit.getDefaultToolkit().systemClipboard
        const val MIN_FONT_SIZE: Int = 8
        const val MAX_FONT_SIZE: Int = 72

        const val QQ_GROUP: String = "715598051"
        const val URL_GITHUB: String = "https://github.com/leewyatt"
        const val EMAIL_GMAIL: String = "leewyatt7788@gmail.com"
        const val EMAIL_163: String = "leewyatt@163.com"

        /**
         * Typora Ver 0.9.98 支持的列表如下
         * plain text 是自行添加的,表示普通文本
         */
        val EXTENSION_LIST: List<String> = mutableListOf(
                "ABAP", "apl", "asciiarmor", "ASN.1", "asp", "assembly",
                "bash", "basic",
                "c", "c#", "c++", "cassandra", "ceylon", "clike", "clojure", "cmake", "cobol", "coffeescript", "commonlisp", "cpp", "CQL", "crystal", "csharp", "css", "cypher", "cython",
                "D", "dart", "diff", "django", "dockerfile", "dtd", "dylan",
                "ejs", "elixir", "elm", "embeddedjs", "erb", "erlang",
                "F#", "flow", "forth", "fortran", "fsharp",
                "gas", "gfm", "gherkin", "glsl", "go", "groovy",
                "handlebars", "haskell", "haxe", "html", "http", "hxml",
                "idl", "ini",
                "jade", "java", "javascript", "jinja2", "js", "json", "jsp", "jsx", "julia",
                "kotlin",
                "latex", "less", "lisp", "livescript", "lua",
                "makefile", "mariadb", "markdown", "mathematica", "matlab", "mbox", "mermaid", "mssql", "mysql",
                "nginx", "nsis",
                "objc", "objective-c", "ocaml", "octave", "oz",
                "pascal", "perl", "perl6", "pgp", "php", "php+HTML", "plsql", "powershell", "properties", "protobuf", "pseudocode", "python", "plain text",
                "R", "react", "reStructuredText", "rst", "ruby", "rust",
                "SAS", "scala", "scheme", "scss", "sequence", "sh", "shell", "smalltalk", "SPARQL", "spreadsheet", "sql", "sqlite", "squirrel", "stylus", "swift",
                "tcl", "tex", "tiddlywiki", "tiki wiki", "toml", "tsx", "twig", "typescript",
                "v", "vb", "vbscript", "velocity", "verilog", "vhdl", "visual basic", "vue",
                "web-idl", "wiki",
                "xaml", "xml", "xml-dtd", "xquery",
                "yacas", "yaml")
    }
}